from django.db import models
from django.db.models import Model
from .base_model import BaseModel


# Create your models here.

# 创建第一个模型类对象 PersonModel
class PersonModel(BaseModel):
    # 所有模型类形，orm提供一个默认主键的ID，类型是Integer 同时自增
    name = models.CharField(max_length=20, unique=True, verbose_name="姓名")
    last_name = models.CharField(max_length=10, null=True, blank=True, verbose_name="姓名")
    age = models.IntegerField(max_length=10, verbose_name="年龄")
    adder = models.CharField(max_length=200, null=True, blank=True, verbose_name="详细地址")

    class Meta:
        db_table = 't_person'
        verbose_name = '人员表'
        verbose_name_plural = verbose_name
        ordering = ['id']

    def __str__(self):
        return f'姓名:{self.name},别名:{self.last_name},年龄：{self.age},地址:{self.adder}'
